<script setup lang="ts">
import TeacherSection from "@/components/index/teacher/TeacherSection.vue";
import {ref} from "vue";
import {teacherContent} from "@/http/home";
import {useRouter} from "vue-router";
import router from "@/router";

//教师列表
let teacherList = ref<any[]>([])
teacherContent({pageNum: 1, pageSize: 10}).then(res => {
    // console.log(res)
    if (res.code === 200) {
        teacherList.value = res.rows
    }else if (res.code==401){
        router.push('/denglu')
    }

});

//跳转到教师详情页面传参
const detailId=useRouter()
function jumpDetail(item) {
    detailId.push({
        path: '/teacherDetail',
        query: {id:item.id}
    })
}

// item传给子组件

const onClickLeft = () => history.back();
</script>

<template>
    <div>
        <van-nav-bar
                :fixed=true
                :placeholder=true
                title="咨询师"
                left-text="返回"
                left-arrow
                @click-left="onClickLeft"
        />
        <teacher-section  v-for="item in teacherList" :key="item.id" @click="jumpDetail(item)" :eachTeacher="item"></teacher-section>
    </div>
</template>

<style scoped>

</style>